<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::group(['namespace' => 'API', 'middleware' => ['auth:api']], function () {
    //获取当前登录人的个人信息
    Route::get('admin/profile', 'AdminController@getProfile');
    Route::post('admin/profile', 'AdminController@updateProfile');
    Route::get('admin/permission', 'AdminController@getUserPermissionList');

    //公共数据
    Route::group(['prefix' => 'data'], function () {
        Route::get('province-list', 'DataProviderController@getProvinceList');
        Route::get('city-list/{provinceId}', 'DataProviderController@getCityList');              //根据省份id获取城市
        Route::get('school-list/{cityId}', 'DataProviderController@getSchoolList');              //根据城市id获取学校
        Route::get('dept-list/{schoolId}', 'DataProviderController@getDeptList');                //根据学校id获取院系
        Route::get('speciality-list/{deptId}', 'DataProviderController@getSpecialityList');      //根据院系id获取专业
        Route::post('set-user-password/{userId}', 'DataProviderController@setUserPassword');
        Route::get('position-title-list', 'DataProviderController@getPositionTitleList');
    });


    /**
     * 教师路由
     */
    Route::resource('teacher', 'TeacherController', [
        'except' => [
            'create', 'edit'
        ]
    ]);
    Route::group(['prefix' => 'teacher'], function () {
        Route::get('force-delete/{id}', 'TeacherController@getForceDelete');
        Route::get('invocation/{id}', 'TeacherController@getInvocation');
        Route::get('open-id-delete/{id}', 'TeacherController@getOpenIdDelete');
        Route::post('upload', 'TeacherController@postUpload');
    });


    /**
     * 学生路由
     */
    Route::resource('student', 'StudentController', [
        'except' => [
            'create', 'edit'
        ]
    ]);
    Route::group(['prefix' => 'student'], function () {
        Route::get('force-delete/{id}', 'StudentController@getForceDelete');            //永久删除学生
        Route::get('invocation/{id}', 'StudentController@getInvocation');               //启用学生
        Route::get('open-id-delete/{id}', 'StudentController@getOpenIdDelete');         //微信解绑
        Route::post('upload', 'StudentController@postUpload');                          //上传表格
    });

    /**
     * 社会人士路由
     */
    Route::resource('company', 'CompanyController', [
        'except' => [
            'create', 'edit'
        ]
    ]);
    Route::group(['prefix' => 'company'], function () {
        Route::get('force-delete/{id}', 'CompanyController@getForceDelete');
        Route::get('invocation/{id}', 'CompanyController@getInvocation');
        Route::get('open-id-delete/{id}', 'CompanyController@getOpenIdDelete');
        Route::post('upload', 'CompanyController@postUpload');
    });


    /**
     * 名校管理
     */
    Route::resource('famous-school', 'FamousSchoolController', [
        'except' => [
            'create', 'edit'
        ]
    ]);
    Route::post('famous-school/file-upload', 'FamousSchoolController@fileUpload');

    /**
     * 名师管理
     */
    Route::resource('famous-teacher', 'FamousTeacherController', [
        'except' => [
            'create',
            'edit'
        ]
    ]);
    Route::group(['prefix' => 'famous-teacher'], function () {
        Route::get('img-list/{famousTeacherId}', 'FamousTeacherController@getImgList');
        //名师上传图片
        Route::post('file-upload/{famousTeacherId}', 'FamousTeacherController@fileUpload');
        //删除名师图片
        Route::get('delete-file/{famousTeacherId}/{fileId}', 'FamousTeacherController@deleteTeacherFile');
        //查询教师
        Route::get('search-teacher/{teacherMobile}', 'FamousTeacherController@getTeacherInfo');
    });


    /**
     * 赛事管理
     */
    Route::resource('award', 'AwardController', [
        'except' => [
            'create',
            'edit'
        ]
    ]);
    Route::group(['prefix' => 'award'], function (){
        Route::get('info/{awardId}', 'AwardController@getInfo');
        Route::get('company/{awardId}', 'AwardController@getCompanies');
        Route::get('award-company/{awardId}/{awardCompanyId}', 'AwardController@getAwardCompany');
        Route::post('award-company/{awardId}', 'AwardController@storeAwardCompany');
        Route::put('award-company/{awardId}/{awardCompanyId}', 'AwardController@updateAwardCompany');
        Route::delete('award-company/{awardId}/{awardCompanyId}', 'AwardController@deleteAwardCompany');
    });


    /**
     * 命题管理
     */
    Route::group(['prefix' => 'proposition'], function (){
        Route::get('select-list/{awardId}', 'PropositionCompanyController@getSelectList');
    });

    /**
     * 作品类别管理
     */
    Route::group(['prefix' => 'works-type'], function (){
        Route::get('select-list', 'WorksTypeController@getSelectList');
    });

});

